﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Diagnostics;

namespace MultiViewer.Display
{
    /// <summary>
    /// Interaction logic for UnhandlerExceptionWindow.xaml
    /// </summary>
    public partial class UnhandlerExceptionWindow : Window
    {
        public UnhandlerExceptionWindow()
        {
            InitializeComponent();
        }

        public void SetExceptionData(Exception exc)
        {
            details.Text = exc.Message + "\n" + exc.StackTrace;
            while (exc.InnerException != null)
            {
                exc = exc.InnerException;
                details.Text += "\nInner exception details:" + exc.Message + "\n" + exc.StackTrace;
            }
        }

        private void OnCopyDetailsClick(object sender, RoutedEventArgs e)
        {
            details.SelectAll();
            details.Copy();
        }

        private void OnCloseClick(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void OnEmailClick(object sender, RoutedEventArgs e)
        {
            Hyperlink link = sender as Hyperlink;
            if (link != null)
                Process.Start(link.NavigateUri.ToString());
        }
    }
}
